<?php
/**
 * Created by PhpStorm.
 * User: LiuJiaJun
 * Date: 2019/3/30
 * Time: 15:26
 */

namespace api\storage\service\client;

use api\storage\common\Constant;
use api\storage\model\ClientVersionModel;

class ApkClientService extends BaseClientService
{

    const APK_TYPE = 1;

    public function initUploadLogRootPath($code)
    {
        $rootPath = Constant::LOG_APK_PATH;
        $append = empty($code) ? '' : $code . '/';
        $path = PUBLIC_PATH . $rootPath . $append;
        return $path;
    }

    public function initVersionData($version)
    {
        $clientVersionModel = new ClientVersionModel();
        if (empty($version)) {
            return $clientVersionModel->queryLatestVersion(self::APK_TYPE);
        }
        list($majorVersion, $minorVersion) = explode('.', $version);
        return $clientVersionModel->queryByVersion(self::APK_TYPE, intval($majorVersion), intval($minorVersion));
    }


    public function initHistoryData()
    {
        $clientVersionModel = new ClientVersionModel();
        return $clientVersionModel->queryHistoryVersion(self::APK_TYPE);
    }
}